{% extends 'base.html' %}
{% load static %}
{% block title %}
    天天生鲜-商品列表
{% endblock %}
{% include 'includes/css.html' %}
{% block content %}
    {% include 'includes/search.html' %}

    <div class="navbar_con">
        <div class="navbar clearfix">
            <div class="subnav_con fl">
                <h1>全部商品分类</h1>
                <span></span>
                <ul class="subnav">
                    {% for type in type_list %}
                        <li><a href="{% url 'goods:g_list' type.pk %}" class="{{ type.logo }}">{{ type.name }}</a></li>
                    {% endfor %}
                </ul>
            </div>
            <ul class="navlist fl">
                <li><a href="{% url 'goods:index' %}">首页</a></li>
                <li class="interval">|</li>
                <li><a href="">手机生鲜</a></li>
                <li class="interval">|</li>
                <li><a href="">抽奖</a></li>
            </ul>
        </div>
    </div>

    <div class="breadcrumb">
        <a href="{% url 'goods:index' %}">全部分类</a>
        <span>></span>
        <a href="#">{{ type_good.name }}</a>
    </div>

    <div class="main_wrap clearfix">
        <div class="l_wrap fl clearfix">
            <div class="new_goods">
                <h3>新品推荐</h3>
                <ul>
                    <li>
                        <a href="#"><img src="{% static 'images/goods/goods001.jpg' %}"></a>
                        <h4><a href="#">进口柠檬</a></h4>
                        <div class="prize">￥3.90</div>
                    </li>
                    <li>
                        <a href="#"><img src="{% static 'images/goods/goods002.jpg' %}"></a>
                        <h4><a href="#">玫瑰香葡萄</a></h4>
                        <div class="prize">￥16.80</div>
                    </li>
                </ul>
            </div>
        </div>

        <div class="r_wrap fr clearfix">
            <div class="sort_bar">
                <a href="?default=1" class="active">默认</a>
                <a href="?priceSore=1">价格</a>
                <a href="?salesSore=1">人气</a>
            </div>

            <ul class="goods_type_list clearfix">
                {% if not object_list %}
                    <img src="{% static 'images/timg.png' %}" alt="">对不起，暂时没有该类型的商品!!!
                {% endif %}
                {% for good in object_list %}
                    <li>
                        <a href="{% url 'goods:g_detail' good.pk %}"><img src="/media/{{ good.image }}"></a>
                        <h4><a href="{% url 'goods:g_detail' good.pk %}">{{ good.name }}</a></h4>
                        <div class="operate">
                            <span class="prize">￥{{ good.price }}</span>
                            <span class="unit">{{ good.unite }}</span>
                            <a href="#" class="add_goods" title="加入购物车"></a>
                        </div>
                    </li>
                {% endfor %}
            </ul>

            <!-- 分页 -->
            <div class="pagenation">
                {% if page_obj.has_previous %}
                    <a href="?page={{ page_obj.previous_page_number }}">上一页</a>
                {% endif %}
                
                {% for page in paginator.page_range %}
                    {% if page == page_obj.number %}
                        <a href="#" class="active">{{ page }}</a>
                    {% else %}
                        <a href="#">{{ page }}</a>
                    {% endif %}
                {% endfor %}
            
                {% if page_obj.has_next %}
                    <a href="?page={{ page_obj.next_page_number }}">下一页></a>
                {% endif %}
            </div>
        </div>
    </div>
{% endblock %}

